<template>
    <el-table :data="tenantListData" style="width: 100%">
        <el-table-column label="租户名称" align="center" prop="tenantName"/>
        <el-table-column label="域名地址" align="center" prop="domain"></el-table-column>
        <el-table-column label="联系人" align="center" prop="linkman"/>
        <el-table-column label="联系电话" align="center" prop="contactNumber"/>
        <el-table-column label="联系地址" align="center" prop="address"/>
        <el-table-column label="用户数量" align="center" prop="userNum"/>
        <el-table-column label="操作" align="center" width="250px">
            <template v-slot="scope">
                <el-button icon="el-icon-edit"
                           @click="handleUpdateTenant(scope.row)">修改
                </el-button>
                <el-button icon="el-icon-delete"
                           @click="handleDeleteTenant(scope.row)">删除
                </el-button>
            </template>
        </el-table-column>
    </el-table>

    <!-- 增加或修改租户信息 -->
    <update-tenant :title="title" :form="form" :open="open"
            v-on:dialogStatusChanged="changeDialogStatus($event)">
    </update-tenant>
</template>

<script>

    import updateTenant from './update.vue'
    import {getTenantList} from '/src/api/system/tenant'

    export default {
        name: "index",
        components: {updateTenant},
        data() {
            return {
                tenantListData: [],
                tenantListTotal: 0,
                queryParams: {
                    pageNum: 1,
                    pageSize: 10,
                },
                //添加修改参数
                title: '',
                form: {},
                open: false,
            }
        },
        created() {
            this.init();
        },
        methods: {
            init() {
                this.getTenantListByParam()
            },
            getTenantListByParam() {
                getTenantList(this.queryParams).then((res) => {
                    this.tenantListData = res.rows
                    this.tenantListTotal = res.total
                })
            },
            handleUpdateTenant(row) {
                this.open = true
                this.form = row
                this.title = '修改租户信息'
            },
            handleDeleteTenant() {

            },
            //更改弹出框的状态
            changeDialogStatus(status) {
                this.open = status
                this.getTenantListByParam()
            },
        },
    }
</script>

<style scoped>

</style>
